﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using webtracuudiem.Truyxuatdulieu;

namespace webtracuudiem.App_Code
{
    public class MyRoleProvider : RoleProvider
    {
       
        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override string ApplicationName
        {
            get;
            set;
        }

        public override void CreateRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            throw new NotImplementedException();
        }

        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            throw new NotImplementedException();
        }

        public override string[] GetAllRoles()
        {
            throw new NotImplementedException();
        }

        public override string[] GetRolesForUser(string username)
        {
            string sqlSelect = "SELECT MaQuyen FROM QuyenNguoiDung WHERE Username=@TenDangNhap";
            DataTable tbl = TienIchSql.ChayLenhSelectDuLieu(sqlSelect, "@TenDangNhap", username);
            string[] mang = new string[tbl.Rows.Count];
            for (int i = 0; i < tbl.Rows.Count; i++)
                mang[i] = (string)tbl.Rows[i][0];
            return mang;
        }

        public override string[] GetUsersInRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool IsUserInRole(string username, string roleName)
        {
            string sqlSelect = "SELECT * FROM QuyenNguoiDung WHERE Username=@TenDangNhap AND MaQuyen=@MaQuyen";
            DataTable tbl = TienIchSql.ChayLenhSelectDuLieu(sqlSelect, "@TenDangNhap", username, "@MaQuyen", roleName);
            return tbl.Rows.Count > 0;
        }

        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override bool RoleExists(string roleName)
        {
            throw new NotImplementedException();
        }
    }
}